Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom .env file path #2315

Merged
merged 2 commits into from
Feb 27, 2022

Conversation

TinfoilSubmarine
Copy link
Contributor

@TinfoilSubmarine TinfoilSubmarine commented Feb 16, 2022

Hi! I'm working on packaging this for Void, and in writing the runit service, I came across an annoyance: since the .env file can't be in the current working directory, it won't find it and thus has to read from the environment variables directly. This can be done with something like:

#!/bin/sh
exec chpst -u _vaultwarden:_vaultwarden \
        env $(grep -v '^#' ${ENV_FILE:-/etc/vaultwarden.env} | xargs -d '\n') vaultwarden

But that is less than ideal IMO. This patch is a simple way to pass a single custom location where the env/config can be found.

Copy link
Contributor

@jjlin jjlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should also be some docs towards the top of https://github.com/dani-garcia/vaultwarden/blob/main/.env.template so people know this env var is available

@TinfoilSubmarine
Copy link
Contributor Author

I should mention that another solution to this is to cd to the directory containing the .env file (or a symlink to it) prior to executing vaultwarden. So my service file would look like:

ln -sf ${ENV_FILE:-/etc/vaultwarden.env} /var/lib/vaultwarden/.env
cd /var/lib/vaultwarden
exec chpst -u _vaultwarden:_vaultwarden vaultwarden

This works for my use case, but I'll leave this PR here in case it's seen as a benefit.

@dani-garcia dani-garcia merged commit 94201ca into dani-garcia:main Feb 27, 2022
@TinfoilSubmarine TinfoilSubmarine deleted the custom-env-path branch February 27, 2022 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants